define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'asset/currencymanage/index',
                    add_url: 'asset/currencymanage/add',
                    edit_url: 'asset/currencymanage/edit',
                    del_url: 'asset/currencymanage/del',
                    multi_url: 'asset/currencymanage/multi',
                    table: 'currency',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'currency_id',
                sortName: 'currency_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'currency_id', title: __('Currency_id')},
                        {field: 'currency_name', title: __('Currency_name')},
                        {field: 'en_name', title: __('En_name')},
                        {field: 'currency_logo', title: __('Currency_logo'),formatter: Table.api.formatter.image},
                        {field: 'currency_mark', title: __('Currency_mark')},
                        {field: 'currency_all_money', title: __('Currency_all_money'), operate:'BETWEEN'},
                        {field: 'currency_all_num', title: __('Currency_all_num'), operate:'BETWEEN'},
                        {field: 'currency_buy_fee', title: __('Currency_buy_fee'), visible:false, operate:'BETWEEN'},
                        {field: 'currency_sell_fee', title: __('Currency_sell_fee'), visible:false, operate:'BETWEEN'},
                        {field: 'currency_transfer_in_fee', title: __('Currency_transfer_in_fee'), visible:false,operate:'BETWEEN'},
                        {field: 'currency_transfer_out_fee', title: __('Currency_transfer_out_fee'), visible:false, operate:'BETWEEN'},
                        {field: 'miner_fee', title: __('Miner_fee'),visible:false, operate:'BETWEEN'},
                        {field: 'port_number', title: __('Port_number'), visible:false},
                        {field: 'rpc_url', title: __('Rpc_url'), visible:false, formatter: Table.api.formatter.url},
                        {field: 'rpc_pwd', title: __('Rpc_pwd'), visible:false},
                        {field: 'rpc_user', title: __('Rpc_user'), visible:false},
                        {field: 'currency_withdraw_max', title: __('Currency_withdraw_max'),visible:false},
                        {field: 'detail_url', title: __('Detail_url'), visible:false, formatter: Table.api.formatter.url},
                        {field: 'wallet_address', title: __('Wallet_address'), visible:false},
                        {field: 'price_up', title: __('Price_up'),visible:false, operate:'BETWEEN'},
                        {field: 'price_down', title: __('Price_down'),visible:false, operate:'BETWEEN'},
                        {field: 'sort', title: __('Sort'), visible:false},
                        {field: 'official_url', title: __('Official_url'), visible:false, formatter: Table.api.formatter.url},
                        {field: 'block_timespan', title: __('Block_timespan'),visible:false},
                        {field: 'block_confirm_count', title: __('Block_confirm_count'),visible:false},
                        {field: 'precision', title: __('Precision')},
                        {field: 'block_height', title: __('Block_height'),visible:false},
                        {field: 'contract_address', title: __('Contract_address'), visible:false},
                        {field: 'wallet_type_id', title: __('Wallet_type_id'),visible:false,},
                        {field: 'wallettype.name', title: __('Wallet_type_id'), operate:false},
                        {field: 'is_lock', title: __('Is_lock'), visible:false, searchList: {"1":__('交易许可'),"2":__('交易不许可')}},
                        {field: 'is_lock_text', title: __('Is_lock'), operate:false},
                        {field: 'is_show', title: __('Is_show'), visible:false, searchList: {"1":__('显示'),"2":__('不显示')}},
                        {field: 'is_show_text', title: __('Is_show'), operate:false},
                        {field: 'default_concern', title: __('Default_concern'), visible:false, searchList: {"0":__('默认不关注'),"1":__('默认关注')}},
                        {field: 'default_concern_text', title: __('Default_concern'), operate:false},
                        {field: 'precision_flag', title: __('Precision_flag'),visible:false, searchList: {"1":__('读取价格乘以精度'),"2":__('读取价格不乘以精度')}},
                        {field: 'precision_flag_text', title: __('Precision_flag'), operate:false},
                        {field: 'add_time', title: __('Add_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});